package com.zhdl.hardware_contact.middleware.middleware_plc.siemens.repository.impl;

import com.zhdl.hardware_contact.middleware.middleware_plc.siemens.repository.SiemensCmdHandleService;
import com.zhdl.network.common_client.CommonTcpClientAfter;
import com.zhdl.network.common_client.CommonTcpClientAnalysis;
import com.zhdl.network.strategy.common_client.CommonProtocolService;
import com.zhdl.network.strategy.common_client.dto.SendReceiverData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service("SiemensTCPIPCmdHandleImpl")
public class SiemensTCPIPCmdHandleImpl implements SiemensCmdHandleService {

    @Resource
    private CommonProtocolService commonProtocolService;

    /**
     * 添加Siemens的网口IP+端口
     *
     * @param sendReceiverData 网口工具
     */
    @Override
    public void addTCPIp(SendReceiverData sendReceiverData) {
        if (sendReceiverData.getProtocols() == null || sendReceiverData.getProtocols().isEmpty()) {
            sendReceiverData.setProtocols(CommonTcpClientAnalysis.COMMON_TCP_ANALYSIS);
        }
        if (sendReceiverData.getAfter() == null || sendReceiverData.getAfter().isEmpty()) {
            sendReceiverData.setAfter(CommonTcpClientAfter.COMMON_TCP_AFTER_SERVICE);
        }
        commonProtocolService.initPort(sendReceiverData);
    }


    public void siemensWrite() {

    }

    public void siemensRead() {

    }
}
